#!/bin/bash

INSTALL_DIR=/usr/local
X264_SRC=../x264-snapshot-20160627-2245
FDKAAC_SRC_DIR=../fdk-aac-0.1.6
FFMPEG_SRC=../ffmpeg-2.8

#rm -rf $INSTALL_DIR

# build x264
cd $X264_SRC
make distclean
./configure --prefix=$INSTALL_DIR \
       --enable-pic \
       --enable-shared \
       --enable-strip \
       --disable-avs \
       --disable-swscale \
       --disable-lavf \
       --disable-ffms \
       --disable-gpac \
       --disable-lsmash 

make -j8 install

echo "======================================== x264 build over  ====================================================="

cd $FDKAAC_SRC_DIR
./autogen.sh
make distclean
./configure --prefix=$INSTALL_DIR --disable-static --enable-shared
make -j8 install

echo "======================================== fdk aac build over  ====================================================="

# build ffmpeg
cd $FFMPEG_SRC
make distclean
./configure --prefix=$INSTALL_DIR \
--enable-runtime-cpudetect \
--extra-cflags="-fPIC -Wfatal-errors -Wno-deprecated -I$INSTALL_DIR/include "  \
--exra-ldflags="-L$INSTALL_DIR/lib " \
--enable-gpl --enable-nonfree --enable-version3 --enable-small \
--enable-shared --disable-static \
--disable-doc --disable-programs --disable-debug --disable-ffmpeg --disable-ffprobe --disable-ffplay --disable-ffserver \
--disable-postproc --disable-avdevice  --disable-avfilter  --disable-swresample \
--disable-everything \
--enable-libx264 --enable-encoder=libx264 \
--enable-libfdk_aac --enable-encoder=libfdk_aac \
--enable-decoder=h264 --enable-decoder=hevc --enable-decoder=aac --enable-decoder=mjpeg \
--enable-muxer=mp4 --enable-muxer=mov --enable-muxer=flv --enable-muxer=hls  \
--enable-muxer=mjpeg --enable-muxer=image2 \
--enable-muxer=rtsp --enable-muxer=rtp --enable-muxer=mpegts --enable-muxer=h264 \
--enable-demuxer=mov --enable-demuxer=h264  --enable-demuxer=mpegts  --enable-demuxer=flv --enable-demuxer=hls\
--enable-demuxer=image2 --enable-demuxer=image_jpeg_pipe --enable-demuxer=mjpeg \
--enable-demuxer=rtsp  --enable-demuxer=rtp  --enable-demuxer=sdp \
--enable-parser=aac --enable-parser=h264 \
--enable-bsf=aac_adtstoasc --enable-bsf=h264_mp4toannexb \
--enable-protocol=file --enable-protocol=hls --enable-protocol=http --enable-protocol=https \
--enable-protocol=rtp --enable-protocol=tcp --enable-protocol=udp  --enable-openssl --enable-protocol=crypto --enable-protocol=tls_openssl \
--enable-protocol=rtmp --enable-protocol=rtmps --enable-protocol=rtmpt --enable-protocol=rtmpe --enable-protocol=rtmpte --enable-protocol=rtmpts \
--enable-encoder=png --enable-decoder=png --enable-parser=png --enable-demuxer=image_png_pipe --enable-muxer=dash \
--enable-encoder=gif --enable-decoder=gif --enable-muxer=gif --enable-demuxer=gif 
  
make -j8 install 



#
